<?php

class fvTurtessXML {
	
	var $xml;
	var $channel;
	
	function TurtessXML() {
		$this->channel = 'http://www2.turtess-online.com.ua/export/';
		$this->xml = file_get_contents ( $channel );
	}
	
	//for PHP >>> 5.x.x
	function __construct() {
		$this->TurtessXML ( 'http://www2.turtess-online.com.ua/export/' );
	}
	
	function getData($channel) {
		$dom = domxml_open_mem ( file_get_contents ( $channel ) );
		$root = $dom->document_element ();
		$entities = $root->get_elements_by_tagname ( 'body' );
		
		foreach ( $entities [0]->child_nodes () as $key => $tour ) {
			foreach ( $this->getAttributes ( $tour ) as $attr ) {
				$Result [$key] [$attr] = iconv ( 'utf-8', 'cp1251', $tour->get_attribute ( $attr ) );
			}
		}
		
		return $Result;
	}
	
	function getFound($channel) {
		$dom = domxml_open_mem ( file_get_contents ( $channel ) );
		$root = $dom->document_element ();
		
		$header = $root->get_elements_by_tagname ( 'header' );
		
		foreach ( $header [0]->child_nodes () as $key => $res ) {
			if ($res->tagname == 'found')
				return $res->get_attribute ( 'value' );
		}
	}
	
	function getDictionary($channel) {
		$dom = @DOMDocument::loadXML ( file_get_contents ( $channel ) );
		$params = $dom->getElementsByTagName ( 'element' );
		foreach ( $params as $param ) {
			foreach ($param->attributes as $key=>$attr){
				$result[$attr->name] = $attr->value;
			}
			$Result[] = $result;
		}
		return $Result;
	}
	
	function getAttributes($node) {
		foreach ( $node->attributes () as $attribute ) {
			$attr [] = $attribute->name;
		}
		return $attr;
	}
	
	function getCountries() {
		return $this->getDictionary ( $this->channel . 'dictionary/countries/' );
	}
	
	function getResorts() {
		return $this->getDictionary ( $this->channel . 'dictionary/resorts/' );
	}
	
	function getHotels() {
		return $this->getDictionary ( $this->channel . 'dictionary/hotels/' );
	}
	
	function getHotelsTypes() {
		return $this->getDictionary ( $this->channel . 'dictionary/stars/' );
	}
	
	function getBoards() {
		return $this->getDictionary ( $this->channel . 'dictionary/boardings/' );
	}
	
	function getFromCities() {
		return $this->getDictionary ( $this->channel . 'dictionary/cities/from/' );
	}
	
	function getToCities() {
		return $this->getDictionary ( $this->channel . 'dictionary/cities/to/' );
	}
	
	function getTours($channel) {
		return $this->getData ( $channel );
	}

}

?>